/*************
author:: libo
license:: MIT
*****************/
#ifndef _LIBCELL_TOOLS_IO_H_
#define _LIBCELL_TOOLS_IO_H_
#include<Mesh_IO/Mesh_IO.h>
#include "libcell_tools_formats.h"
#include <libcell_macros.h>

#define _ReadFile_ LibCell_ReadFile_
#define _WriteMesh_ LibCell_WriteMesh_

#ifdef __cplusplus
extern "C" {
#endif
static int  _ReadFile_(Mesh*mesh,char const * filename)
{
   const char* suf=filename_suffix(filename,'.');
   if(strcmp(suf,"off")==0)
   {
      return  _ReadOff_(mesh ,filename,3);
   } 
   else if(strcmp(suf,"stl")==0)
   {
      return _ReadStl_(mesh, filename);
   }
   else if(strcmp(suf,"obj")==0 )
   {
      return _ReadObj_(mesh, filename);
   }
   else if( strcmp(suf,"ply")==0)
   {
      return  _ReadPly_(mesh, filename);
   }
   else if(strcmp(suf,"cell")==0)
   {
      return  _ReadCell_(mesh, filename);
   }


    
    return 0;
}


static int _WriteMesh_( Mesh*mesh,char const * filename)
{
   const char* suf=filename_suffix(filename,'.');
   if(strcmp(suf,"off")==0)
   {
      return  _WriteOff_(mesh ,filename);
   } 
   else if(strcmp(suf,"cell")==0)
   {
      return _WriteCell_(mesh, filename);
   } 
   return 1;
}









#ifdef __cplusplus
}
#endif

#undef _ReadFile_
#undef _WriteMesh_
#endif